function formatTime(time) {
    const dateObj = new Date(time);

    // 获取月份和日期
    const month = dateObj.getMonth() + 1; // 月份从0开始，需要加1
    const day = dateObj.getDate();

    // 获取小时和分钟
    const hours = dateObj.getHours();
    const minutes = dateObj.getMinutes();

    // 将月份、日期、小时和分钟格式化为两位数
    const formattedMonth = month.toString().padStart(2, '0');
    const formattedDay = day.toString().padStart(2, '0');
    const formattedHours = hours.toString().padStart(2, '0');
    const formattedMinutes = minutes.toString().padStart(2, '0');

    // 组合成新的格式：日月和时分
    const formattedTime = formattedDay + '-' + formattedMonth + ' ' + formattedHours + ':' + formattedMinutes;
    // console.log(formattedTime);
    return formattedTime;
}

const formattedTime = formatTime('');





function formatNumber(number) {
    if (number >= 10000) {
        const formattedNumber = (number / 10000).toFixed(1) + 'w';
        return formattedNumber;
    } else {
        return number.toString();
    }
}

const formattedNumber = formatNumber('');
// console.log(formattedNumber);






let page = 0
async function renderPage() {
    page++
    let str = ''
    let params = {
        page
    }
    let data = await getData('v1/special/list', params, 'uwYih4TRT5AUmTc3RLMKYX6EVeBPzWqiObCifal3iPNi+ngcLAcO2As6qObgc6bL')

    data.data.dataList.forEach((ele) => {
        console.log(ele)
        str +=
            `
            <div class="special-item">
            <a href="">
                <div class="special-item-cover"
                    style="background-image: url(${ele.picture});">
                    <div class="special-item-mask">
                        <span class="special-label01">专题</span>
                        <div class="special-text-title">${ele.title}</div>
                    </div>
                </div>
                <div class="special-item-desc">
                    <div class="special-item-desc-title">${ele.introduction}</div>
                    <div class="special-item-bottom">
                        <div class="special-item-bottom-time">${formatTime(ele.publishTime)}</div>
                        <div class="special-item-bottom-view">${formatNumber(ele.readCount)}</div>
                        <div class="special-item-bottom-comment">${ele.supportCount}</div>
                    </div>
                </div>
            </a>
        </div>
             `
    })
    $('.van-list').append(str)
}
renderPage()
let _load = true
window.addEventListener('scroll', function () {
    // 检查是否滚动到页面底部
    if (document.documentElement.scrollTop + window.innerHeight >= document.documentElement.scrollHeight - 100 && _load) {
        // 在此处加载更多内容
        renderPage()
        setTimeout(() => {
            _load = true;
        }, 2500);
        _load = false;
    }
});